#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
map<double,bool>map1;
int main(void)
{
  	cin.tie(0);std::ios::sync_with_stdio(false);
    int t;cin>>t;
    while(t--){
        map1.clear();
        LL p,q,b;cin>>p>>q>>b;
        double num=1.0*p/(1.0*q);
        if(num>=1.0){
            LL cnt=num;
            num-=1.0*cnt;
        }
        bool flag=1;
        while(1){
            printf("%.10f\n",num);
            if(map1.count(num)){
                flag=0;
                break;
            }
            else map1[num]=true;
            num*=p;
            LL temp=num;
            if(temp*1.0==num){
                break;
            }
            if(num>=1.0){
                LL cnt=num;
                num-=1.0*cnt;
            }
        }
        if(flag) cout<<"Finite"<<"\n";
        else cout<<"Infinite"<<"\n";
    }
return 0;
}
